package com.tianji.remark;

import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableScheduling;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @ProjectName: ${PROJECT_NAME}
 * @Package: com.tianji
 * @ClassName: ${NAME}
 * @Author: 王加其
 * @Date: ${DATE} ${TIME}
 * @Version: 1.0
 */
    @Slf4j
    @EnableScheduling
    @SpringBootApplication
    @MapperScan("com.tianji.remark.mapper")
    public class RemarkApplication {
        public static void main(String[] args) throws UnknownHostException {
            SpringApplication app = new SpringApplicationBuilder(RemarkApplication.class).build(args);
            Environment env = app.run(args).getEnvironment();
            String protocol = "http";
            if (env.getProperty("server.ssl.key-store") != null) {
                protocol = "https";
            }
            log.info("--/\n---------------------------------------------------------------------------------------\n\t" +
                            "Application '{}' is running! Access URLs:\n\t" +
                            "Local: \t\t{}://localhost:{}\n\t" +
                            "External: \t{}://{}:{}\n\t" +
                            "Profile(s): \t{}" +
                            "\n---------------------------------------------------------------------------------------",
                    env.getProperty("spring.application.name"),
                    protocol,
                    env.getProperty("server.port"),
                    protocol,
                    InetAddress.getLocalHost().getHostAddress(),
                    env.getProperty("server.port"),
                    env.getActiveProfiles());
        }
    }